<template>
	<template v-if="order">
		<div class="order-detail">
			<h2>订单详情</h2>
			<el-descriptions :column="2" border>
				<el-descriptions-item label="订单编号">{{ order.orderNo }}</el-descriptions-item>
				<el-descriptions-item label="批次号">{{ order.batchNo }}</el-descriptions-item>
				<el-descriptions-item label="产品名称">{{ order.product }}</el-descriptions-item>
				<el-descriptions-item label="订单数量">{{ order.quantity }}</el-descriptions-item>
				<el-descriptions-item label="订单状态">
					<el-tag :type="statusTagType(order.status)">{{ order.status }}</el-tag>
				</el-descriptions-item>
				<el-descriptions-item label="下单日期">{{ order.orderDate }}</el-descriptions-item>
				<el-descriptions-item label="交付日期">{{ order.deliveryDate }}</el-descriptions-item>
				<el-descriptions-item label="客户">{{ order.customer }}</el-descriptions-item>
				<el-descriptions-item label="联系方式">{{ order.customerContact }}</el-descriptions-item>
				<el-descriptions-item label="生产线编号">{{ order.productionLine }}</el-descriptions-item>
				<el-descriptions-item label="生产负责人">{{ order.productionManager }}</el-descriptions-item>
				<el-descriptions-item label="生产计划">{{ order.productionPlan }}</el-descriptions-item>
				<el-descriptions-item label="交付进度">{{ order.progress }}</el-descriptions-item>
				<el-descriptions-item label="备注">{{ order.notes || '-' }}</el-descriptions-item>
			</el-descriptions>
			<div class="btns">
				<el-button @click="$router.back()">返回</el-button>
			</div>
		</div>
	</template>
	<template v-else>
		<div style="text-align: center; padding: 60px 0;">
			<el-empty :image-size="100" description="订单信息未找到" />
			<el-button type="primary" @click="$router.push('/orders/list')" style="margin-top: 24px;">
				返回订单列表
			</el-button>
		</div>
	</template>
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { useRoute } from 'vue-router'


const route = useRoute()
const order = ref(null)

onMounted(() => {
	const id = Number(route.params.id)
	order.value = orderDetails.find(o => o.id === id)
})


const orderDetails = [
	{
		id: 1,
		orderNo: 'ORD2024060101',
		batchNo: 'BATCH-240601-01',
		product: '注射用头孢曲松钠',
		quantity: 500,
		status: '待生产',
		customer: '华西药业',
		customerContact: '028-88881234',
		orderDate: '2024-06-01',
		deliveryDate: '2024-06-08',
		productionLine: 'L01',
		productionManager: '张伟',
		productionPlan: '2024-06-03 开始，计划3天完成',
		progress: '未开始',
		notes: '常规订单，优先级一般'
	},
	{
		id: 2,
		orderNo: 'ORD2024060102',
		batchNo: 'BATCH-240601-02',
		product: '葡萄糖注射液',
		quantity: 1200,
		status: '生产中',
		customer: '济民制药',
		customerContact: '021-66667777',
		orderDate: '2024-06-01',
		deliveryDate: '2024-06-09',
		productionLine: 'L02',
		productionManager: '李强',
		productionPlan: '2024-06-02 开始，计划4天完成',
		progress: '已完成60%',
		notes: '需冷链配送'
	},
	{
		id: 3,
		orderNo: 'ORD2024060103',
		batchNo: 'BATCH-240601-03',
		product: '氯化钠注射液',
		quantity: 2000,
		status: '已完成',
		customer: '百洋药业',
		customerContact: '0532-55553333',
		orderDate: '2024-06-01',
		deliveryDate: '2024-06-07',
		productionLine: 'L03',
		productionManager: '王芳',
		productionPlan: '2024-06-01 开始，已完成',
		progress: '100%',
		notes: '定制标签，需专人验收'
	},
	{
		id: 4,
		orderNo: 'ORD2024060201',
		batchNo: 'BATCH-240602-01',
		product: '阿莫西林胶囊',
		quantity: 1000,
		status: '待生产',
		customer: '国控广州',
		customerContact: '020-44445555',
		orderDate: '2024-06-02',
		deliveryDate: '2024-06-10',
		productionLine: 'L02',
		productionManager: '李强',
		productionPlan: '2024-06-05 开始，计划2天完成',
		progress: '未开始',
		notes: ''
	},
	{
		id: 5,
		orderNo: 'ORD2024060202',
		batchNo: 'BATCH-240602-02',
		product: '维生素C片',
		quantity: 3000,
		status: '已完成',
		customer: '山东罗欣',
		customerContact: '0633-11112222',
		orderDate: '2024-06-02',
		deliveryDate: '2024-06-08',
		productionLine: 'L01',
		productionManager: '张伟',
		productionPlan: '2024-06-03 开始，已完成',
		progress: '100%',
		notes: '发货需提前一天预约'
	},
	{
		id: 6,
		orderNo: 'ORD2024060203',
		batchNo: 'BATCH-240602-03',
		product: '地塞米松磷酸钠注射液',
		quantity: 650,
		status: '生产中',
		customer: '广州医药集团',
		customerContact: '020-33334444',
		orderDate: '2024-06-02',
		deliveryDate: '2024-06-12',
		productionLine: 'L04',
		productionManager: '赵勇',
		productionPlan: '2024-06-06 开始，计划3天完成',
		progress: '已完成50%',
		notes: ''
	},
	{
		id: 7,
		orderNo: 'ORD2024060301',
		batchNo: 'BATCH-240603-01',
		product: '硫酸庆大霉素注射液',
		quantity: 800,
		status: '待生产',
		customer: '太极集团',
		customerContact: '023-66668888',
		orderDate: '2024-06-03',
		deliveryDate: '2024-06-13',
		productionLine: 'L01',
		productionManager: '张伟',
		productionPlan: '2024-06-08 开始，计划2天完成',
		progress: '未开始',
		notes: ''
	},
	{
		id: 8,
		orderNo: 'ORD2024060302',
		batchNo: 'BATCH-240603-02',
		product: '阿奇霉素片',
		quantity: 700,
		status: '已完成',
		customer: '复星医药',
		customerContact: '021-12345678',
		orderDate: '2024-06-03',
		deliveryDate: '2024-06-09',
		productionLine: 'L03',
		productionManager: '王芳',
		productionPlan: '2024-06-05 开始，已完成',
		progress: '100%',
		notes: ''
	},
	{
		id: 9,
		orderNo: 'ORD2024060303',
		batchNo: 'BATCH-240603-03',
		product: '氢氯噻嗪片',
		quantity: 1100,
		status: '生产中',
		customer: '正大天晴',
		customerContact: '025-22221111',
		orderDate: '2024-06-03',
		deliveryDate: '2024-06-15',
		productionLine: 'L02',
		productionManager: '李强',
		productionPlan: '2024-06-07 开始，计划3天完成',
		progress: '已完成70%',
		notes: ''
	},
	{
		id: 10,
		orderNo: 'ORD2024060401',
		batchNo: 'BATCH-240604-01',
		product: '头孢呋辛酯片',
		quantity: 950,
		status: '已完成',
		customer: '华润三九',
		customerContact: '0755-12341234',
		orderDate: '2024-06-04',
		deliveryDate: '2024-06-11',
		productionLine: 'L03',
		productionManager: '王芳',
		productionPlan: '2024-06-05 开始，已完成',
		progress: '100%',
		notes: '需分两批交付'
	},
	{
		id: 11,
		orderNo: 'ORD2024060402',
		batchNo: 'BATCH-240604-02',
		product: '布洛芬缓释胶囊',
		quantity: 1300,
		status: '待生产',
		customer: '扬子江药业',
		customerContact: '025-55556666',
		orderDate: '2024-06-04',
		deliveryDate: '2024-06-16',
		productionLine: 'L01',
		productionManager: '张伟',
		productionPlan: '2024-06-10 开始，计划4天完成',
		progress: '未开始',
		notes: ''
	},
	{
		id: 12,
		orderNo: 'ORD2024060403',
		batchNo: 'BATCH-240604-03',
		product: '甲硝唑片',
		quantity: 900,
		status: '已完成',
		customer: '江苏恒瑞',
		customerContact: '0511-88887777',
		orderDate: '2024-06-04',
		deliveryDate: '2024-06-14',
		productionLine: 'L02',
		productionManager: '李强',
		productionPlan: '2024-06-08 开始，已完成',
		progress: '100%',
		notes: ''
	},
	{
		id: 13,
		orderNo: 'ORD2024060501',
		batchNo: 'BATCH-240605-01',
		product: '氯雷他定片',
		quantity: 600,
		status: '生产中',
		customer: '北京同仁堂',
		customerContact: '010-66668888',
		orderDate: '2024-06-05',
		deliveryDate: '2024-06-18',
		productionLine: 'L04',
		productionManager: '赵勇',
		productionPlan: '2024-06-12 开始，计划2天完成',
		progress: '已完成40%',
		notes: ''
	},
	{
		id: 14,
		orderNo: 'ORD2024060502',
		batchNo: 'BATCH-240605-02',
		product: '碳酸氢钠注射液',
		quantity: 1550,
		status: '待生产',
		customer: '石药集团',
		customerContact: '0311-12349999',
		orderDate: '2024-06-05',
		deliveryDate: '2024-06-20',
		productionLine: 'L03',
		productionManager: '王芳',
		productionPlan: '2024-06-15 开始，计划4天完成',
		progress: '未开始',
		notes: '急单，优先排产'
	},
	{
		id: 15,
		orderNo: 'ORD2024060503',
		batchNo: 'BATCH-240605-03',
		product: '多潘立酮片',
		quantity: 800,
		status: '生产中',
		customer: '云南白药',
		customerContact: '0871-12341234',
		orderDate: '2024-06-05',
		deliveryDate: '2024-06-17',
		productionLine: 'L02',
		productionManager: '李强',
		productionPlan: '2024-06-10 开始，计划2天完成',
		progress: '已完成30%',
		notes: ''
	}
]


function statusTagType(status) {
	return status === '已完成'
		? 'success'
		: status === '生产中'
			? 'warning'
			: status === '待生产'
				? 'info'
				: ''
}

</script>
<style scoped>
.order-detail {
	max-width: 550px;
	margin: 0 auto;
	padding: 20px 0;
}

.btns {
	margin-top: 30px;
	text-align: center;
}
</style>
